package com.allnas.springcloud.web;

import lombok.extern.slf4j.Slf4j;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @author zhaojin
 */
@Slf4j
@RestController
public class IndexController {

    @Resource
    private RestTemplate restTemplate;

    @GetMapping("info")
    public String info(String userName) {
        log.info("userName:{}", userName);
        return restTemplate.exchange("http://producer/info?userName=" + userName, HttpMethod.GET, null, new ParameterizedTypeReference<String>() {
        }).getBody();
    }
}
